from setuptools import setup, find_packages
import compiler, os, pydoc
from compiler import visitor

package_dir = 'src'

def split_doc_from_module(modfile):
    class ModuleVisitor(object):
        def __init__(self):
            self.mod_doc = None
        def visitModule(self, node):
            self.mod_doc = node.doc
    ast = compiler.parseFile(modfile)
    modnode = ModuleVisitor()
    visitor.walk(ast, modnode)
    if modnode.mod_doc is None:
        raise RuntimeError(
            "could not parse doc string from %s (does the file exist and contain a docstring?)" % modfile)
    return pydoc.splitdoc(modnode.mod_doc)

description, long_description = split_doc_from_module(os.path.join(package_dir, 'sv.py'))

setup(
    name = "sv",
    version = "0.2",
    # if sv becomes sv/__init__.py all you need is:
    # packages = find_packages(),
    py_modules = ['sv'],
    package_dir = {'': package_dir},
    zip_safe = False,
    
    install_requires = ['lxml'],

    entry_points = { 
        'console_scripts': [ 'sv = sv:main' ] 
    },

    # metadata for upload to PyPI
    author = "Luke Opperman, Dan Bravender, Kumar McMillan",
    author_email = "loppear@gmail.com",
    description = description,
    long_description = long_description,
    license = "GPL",
    keywords = "sv subversion branching merging",
    url = "http://code.google.com/p/sv-subversion/",
)